home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 May & June / Amiga-CD 1996 #5-6.iso / demos / finaldata / fdmacros / restorelayout < prev    next >
Text File  |  1996-03-22  |  3KB  |  88 lines

  1. /* ========================================================== */
  2. /* Final Data ARexx Macro.                                    */
  3. /* RestoreLayout - Restore column positions and widths.       */
  4. /* $VER: RestoreLayout 1.0 (4.8.94)                           */
  5. /* © 1994 SoftWood, Inc.                                      */
  6. /* Use of this macro is strictly at the user's risk.          */
  7. /*                                                            */
  8. /* This macro is used in conjunction with the SaveLayout      */
  9. /* macro. Together they will allow you to save the current    */
  10. /* column layout (positions and widths) and then at a later   */
  11. /* time restore the column layout to what is was previously.  */
  12. /* To restore a previous layout, you must first have used the */
  13. /* SaveLayout macro to create a layout file. Start the macro  */
  14. /* from Final Data. The column layout will be set to the data */
  15. /* that is found in the layout file.                          */
  16. /* ========================================================== */
  17. OPTIONS RESULTS
  18.  
  19. /* ---------------------------------------------------------------- */
  20. /* Turn off current selection. If we can't then exit with an error. */
  21. /* ---------------------------------------------------------------- */
  22. SelectOff
  23. IF ( RC ~= 0 ) THEN DO
  24.    ShowMessage 1 1 '"Cannot continue." "Check cell for invalid data." "" "OK" "" ""'
  25.    EXIT 10
  26. END
  27.  
  28. /* ----------------------------- */
  29. /* Determine the layout filename */
  30. /* and try to open it.           */
  31. /* ----------------------------- */
  32. Filename COMPLETE
  33. layoutFile = RESULT || ".FDLayout"
  34. quotedFile = '"' || layoutFile || '"'
  35.  
  36. IF ( OPEN('thefile', layoutFile, 'Read') ) THEN DO
  37.    /* ----------------------------------------------- */
  38.    /* The layout file was opened.                     */
  39.    /* The layout file contains information for each   */
  40.    /* column on each line. Each line has the columnid */
  41.    /* followed by the column width. The lines in the  */
  42.    /* file are in the order that the columns are to   */
  43.    /* appear in the database.                         */
  44.    /* ----------------------------------------------- */
  45.    cpos = 1
  46.    DO FOREVER
  47.       /* --------------------------- */
  48.       /* Read the next line of data. */
  49.       /* If the line is empty we are */
  50.       /* at the end of the file.     */
  51.       /* --------------------------- */
  52.       dataline = READLN('thefile')
  53.       IF ( dataline = "" ) THEN LEAVE
  54.  
  55.       err = 1
  56.       PARSE VAR dataline cid cwidth
  57.       InitModifyColumn cid
  58.       IF ( RC = 0 ) THEN DO
  59.          DefineColumn POSITION cpos WIDTH cWidth
  60.          IF ( RC = 0 ) THEN DO
  61.             ModifyColumn
  62.             IF ( RC = 0 ) THEN DO
  63.                cpos = cpos + 1
  64.                err = 0;
  65.             END
  66.          END
  67.       END
  68.  
  69.       /* ------------------- */
  70.       /* Check if any errors */
  71.       /* ------------------- */
  72.       IF ( err ) THEN DO
  73.          ShowMessage 1 1 '"Error restoring columns." "" "" "OK" "" ""'
  74.          LEAVE
  75.       END
  76.    END   /* Do forever */
  77.  
  78.    CALL CLOSE('thefile')
  79. END   /* End OPEN */
  80.  
  81. ELSE DO
  82.    /* ------------------------------- */
  83.    /* layout file could not be opened */
  84.    /* ------------------------------- */
  85.    firstLine = '"Cannot open file."'
  86.    ShowMessage 1 1 firstLine quotedFile '"" "OK" "" ""'
  87.    EXIT 10
  88. END